package com.rules.admin.controller;


import com.rules.admin.login.UserHolder;
import com.rules.admin.service.ProjectService;
import com.rules.admin.vo.ProjectRoleVO;
import com.rules.admin.vo.RuleUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

@Controller
@RequestMapping({"/updatePermission"})
public class UpdatePermissionController {
   @Autowired
   private UserHolder<RuleUser> userHolder;
   @Autowired
   private ProjectService projectService;

   @RequestMapping(
      method = {RequestMethod.GET}
   )
   @ResponseBody
   public Map<Long, ProjectRoleVO> getPermission() {
      RuleUser ruleUser = (RuleUser)this.userHolder.getUser();
      return this.projectService.getProjectRoleVOs(ruleUser.getId());
   }
}
